<template>
    <el-dialog v-model="dialogVisible" title="编辑工程信息" width="700px">
        <el-form :model="editForm">
            <el-form-item label="项目名称">
                <el-input v-model="editForm.name"></el-input>
            </el-form-item>
            <el-form-item label="创建时间">
                <el-date-picker v-model="editForm.createdTime"  type="date" value-format="YYYY-MM-DD" ></el-date-picker>
            </el-form-item>
            <el-form-item label="抽取专家时间">
                <el-date-picker v-model="editForm.expertSelectionTime"  type="date" value-format="YYYY-MM-DD" ></el-date-picker>
            </el-form-item>
        </el-form>
        <template #footer>
            <el-button @click="dialogVisible = false">取消</el-button>
            <el-button type="primary" @click="saveProject">保存</el-button>
        </template>
    </el-dialog>
</template>
<script setup>
import { updateProject } from '@/alova/api';
import { defineEmits, ref } from 'vue';

const dialogVisible = ref(false);
const editForm = ref({});
const emit = defineEmits(['ProjectModified']);

const openDialog = (data) => {
    editForm.value = { ...data };
    dialogVisible.value = true;
};

const saveProject = async () => {
    console.log('保存工程信息:', editForm.value);
    dialogVisible.value = false;
    try {
    await updateProject(editForm.value);
    dialogVisible.value = false;
    emit('ProjectModified'); // 通知父组件刷新数据
  } catch (error) {
    console.error('修改失败', error);
  }
};
defineExpose({ openDialog });
</script>